from django.conf.urls.defaults import *
from django.contrib import admin
#from django.contrib import databrowse
from ehmn.models import * #for the generic views rea_list_info etc, may need to update for ehmn2
#from ehmn.views import *
from ehmn.feeds import *
#from nets.views import *
admin.autodiscover()
#from tb.models import *

#generic views
from django.views.generic.simple import direct_to_template
from django.views.generic import list_detail
from django.contrib.auth.decorators import login_required

rea_list_info={"queryset" : Reaction.objects.all(),
          "template_name" : "reaction_list.html", 
          "template_object_name" : "reaction",
#         "paginate_by" : 50,
}
rea_detail_info = {
    "queryset" : Reaction.objects.all(),
    "template_object_name" : "reaction", #in template use this name to call the objects
    "template_name" : "reaction_detail.html",
#    "object_id" : "reactionid",
}
com_list_info={"queryset" : Compound.objects.all(),
          "template_name" : "compound_list.html", 
          "template_object_name" : "compound",
}
com_detail_info = {
    "queryset" : Compound.objects.all(),
    "template_object_name" : "compound", #in template use this name to call the objects
    "template_name" : "compound_detail.html",
}
gene_list_info={"queryset" : Gene.objects.all(),
          "template_name" : "gene_list.html", 
          "template_object_name" : "gene",
          "paginate_by" : 500,
}
path_list_info={"queryset" : Pathway.objects.all(),
          "template_name" : "path_list.html", 
          "template_object_name" : "path",
}
path_list_info1={"queryset" : Pathway.objects.all(),
          "template_name" : "path_list1.html", 
          "template_object_name" : "path",
}
path_list_info2={"queryset" : Pathway.objects.all(),
          "template_name" : "path_list2.html", 
          "template_object_name" : "path",
}
gene_detail_info = {
    "queryset" : Gene.objects.all(),
    "template_object_name" : "gene", #in template use this name to call the objects
    "template_name" : "gene_detail.html",
}
urlpatterns = patterns('',
     (r'^account/', include('human.register.urls')),
     (r'^admin/(.*)', admin.site.root),
#     (r'^accounts/', include('registration.urls')),
#     (r'^accounts/login/$', 'django.contrib.auth.views.login'),

#     (r'^tbpathway/', include('human.tb.urls')), #a way to have seperate urls file in differet applications
#     (r'^tbpathway/$', 'human.tb.views.showpaths'),
#     (r'^tbpathway/(?P<pname>.+)/$', 'human.tb.views.showpath'),

     (r'^clssedi/$', 'human.igem.views.clssreg'),
     (r'^completeclss/$', direct_to_template,{'template':'clsscomplete.html'}),
     (r'^fba/$', 'human.ktool.viewsfba.fba'),
     (r'^netdec/$','human.ehmn.netdecview.netdec'),
     (r'^net/dec/$', 'human.ehmn.netdecview.netdec'),
     (r'^igem/$','human.igem.views.model_buider'),
     (r'^stock/$','human.igem.views.stockview'),
     (r'^tv/(?P<ch>.+)/$','human.igem.views.tvview'),
     (r'^sbmltool/$','human.igem.views.upload_file'),
     (r'^sbmlmerge/$','human.igem.views.sbmlmerge'),
     (r'^blast/$', 'human.igem.views.blastpart'),
     (r'^part/$', 'human.igem.views.partslist'),
     (r'^help/$', direct_to_template,{'template':'methods.html'}),
     (r'^partlink/$', 'human.igem.views.partlink'),
     (r'^part/(?P<partid>.+)/$', 'human.igem.views.viewpart'),
#     (r'^part2/(?P<partid>.+)/$', 'human.igem.views.viewpart2'),
     (r'^pcomponent/(?P<gid>.+)/$', 'human.igem.views.viewcomp'),
     (r'^pgroup/$', 'human.igem.views.groupslist'),
     (r'^pgroup/(?P<gid>.+)/$', 'human.igem.views.viewgroup'),
     (r'^mit/(?P<partid>.+)/$', 'human.igem.views.mitview'),
#     (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': 'C:/python25/lib/site-packages/django/human/media/'}),
     # r means python row string, allows regular expression to be written
     #(^) means "require that the pattern matches the start of the string,"
     #($) means "require that the pattern matches the end of the string." 
)

urlpatterns += patterns('human.ktool.views',
	(r'^kneva/$', 'searchnew'),
#	(r'^kneva/rea/list/$', 'reaview'),
	(r'^kneva/rea/text/$', 'rlisttxt'),
	(r'^kneva/rea/sbml/$', 'rlistsbml'),
	(r'^kneva/rea/stoi/$', 'stoimatrix'),
	(r'^kneva/rea/compl/$', 'complist'),
#	(r'^kneva/rea/matrix/$', 'rlistmat'),
#	(r'^knev/rea/vis/$', 'rlistvis'),
	(r'^kneva/metg/(?P<method>.+)/$', 'metgraph'),
	(r'^kneva/reag/(?P<method>.+)/$', 'reagraph'),
	(r'^kneva/bipg/(?P<method>.+)/$', 'bipgraph'),
	(r'^kneva/cyto/(?P<method>.+)/$', 'cytoscapelayout'),
#	(r'^kneva/rea/reag/$', 'rlistrea'),
	(r'^kneva/attr/cytoscape/$', 'attcyto'),
	(r'^kneva/attr/text/$', 'atttxt'),
#	(r'^net/vis/$', 'mgraphvisnew'),
	(r'^net/vism/$', 'mgraphvisnew'),
	(r'^net/visr/$', 'rgraphvis'), #rgraph and bipartitegraph, no hyperlink
	(r'^net/visb/$', 'bgraphvis'), #rgraph and bipartitegraph, no hyperlink
	(r'^net/path/$', 'shortpath'),
#	(r'^net/dec/$', 'netdec'),
	(r'^net/degree/(?P<option>.+)/$', 'degdis'),
	(r'^net/centrality/(?P<option>.+)/$', 'centrality'),
	(r'^net/save/(?P<option>.+)/$', 'savegraph'),
	(r'^net/open/(?P<option>.+)/$', 'opengraph'),
	(r'^net/connectivity/(?P<option>.+)/$', 'connectivity'),
#	(r'^kneva/mgraph/path/$', 'mgpath'),
	(r'^kneva/update/reacomp/$', 'reacomp'),
	(r'^kneva/update/reversibility/$', 'addreversibility'),
	(r'^kneva/update/rgraphmz/$', 'reagraph1mz'),
	(r'^kneva/update/rgraphkr/$', 'reagraph2kr'),
#	(r'^kneva/test/$', 'testmenu'),
    (r'^kegg/(?P<op>.+)/(?P<id>.+)/$', 'keggview'),
    (r'^kneva/help/$', direct_to_template,{'template':'knevahelp.html'}),
)
urlpatterns += patterns('human.ehmn2.views',
	(r'^ehmn2/$', 'search'),
 	(r'^ehmn2/vis/$', 'mgraphvisnew'),
	(r'^humandb/$', 'search'),
 	(r'^humandb/vis/$', 'mgraphvisnew'),
)

urlpatterns += patterns('human.ehmn.views',
     (r'^reaction/$', list_detail.object_list, rea_list_info),
     (r'^reaction/(?P<reactionid>\w+)/$', 'readetail'),
     (r'^search/$', 'search'),
     (r'^global/$', 'showglobalnet'),
     (r'^compound/$', list_detail.object_list, com_list_info),
     (r'^compound/(?P<slug>\w+)/$', list_detail.object_detail, dict(com_detail_info, slug_field='compoundid')),
     (r'^gene/$', list_detail.object_list, gene_list_info),
     (r'^gene/(?P<gid>.+)/$', 'genedetail'),
     (r'^pathway1/$', list_detail.object_list, path_list_info1),
     (r'^pathway2/$', list_detail.object_list, path_list_info2),
     (r'^pathway/$', login_required(list_detail.object_list), path_list_info), #login protect for generic view
     (r'^pathway/(?P<pname>.+)/$', 'showpath'),
     (r'^pathgraph/(?P<pname>.+)/$', 'showpathgraph'),
     (r'^sbml/(?P<pname>.+)/$', 'showSBML'),
#     (r'^pathsvg/(?P<pname>.+)/$', 'showpathsvg'),
     (r'^ehmn/vis/$', 'mgraphvisnew'),
     (r'^path/$', 'shortpath'),
#     (r'^path2/$', 'shortpathold'),
     (r'^pathloc/(?P<pname>.+)/(?P<loname>.+)/$', 'showpathloc'),
     (r'^pathloc2/(?P<pname>.+)/(?P<loname>.+)/$', 'showpathloc2'),
#     (r'^maps/(?P<pname>.+)/$', 'showpgraph'), #not use because handeled by Apache directly
     (r'^msbsupp/$', direct_to_template,{'template':'msbsupp.html'}),
     (r'^humap/$', 'searchhumap'),
     (r'^goviewrea/(?P<go>.+)/$', 'goviewrea'),
     (r'^goviewgene/(?P<go>.+)/$', 'goviewgene'),
     (r'^sta/$', 'stana'),
#     (r'^humap/(?P<id>.+)/$', list_detail.object_detail, humap_detail_info),
#     (r'^pgraph/(?P<pname>[-, \w\(\)\&]+)/$', 'showpgraph'),
#     (r'^pathgraph/(?P<pname>[-, \w\(\)\&]+)/$', 'showpathgraph'),
     #(r'^reaction/(?P<object_id>\w+)/$', list_detail.object_detail, rea_detail_info),
     # ?P means the variable name for the regular expression group used in the view
     #(r'^reaction/(?P<slug>[-\w]+)/$', list_detail.object_detail, dict(rea_detail_info, slug_field='reactionid')),
    # (r'^databrowse/(.*)', databrowse.site.root),
    # (r'^about/$', direct_to_template, {'template': 'about.html'}),
    # (r'^about/(w+)/$', about_pages),
#     (r'^search1/$', 'search1'),
     (r'^/?$', 'search1'),
                        
#     (r'^ehmn/?$', 'search1'),
#     (r'^reaction/add/$', 'add_rea'),
#     (r'^reaction/thanks/$', 'thanks'),
)
#to add css to development
#if settings.DEBUG:
#    urlpatterns += patterns('',
#     (r'^site_media/(.*)$', 'django.views.static.serve',
#      {'document_root': settings.BASE_REL('media')})
site_feeds= {'pathway':PathFeed}
urlpatterns += patterns('',
     (r'^feeds/(?P<url>.*)/$','django.contrib.syndication.views.feed',{'feed_dict':site_feeds}),
)
